/**
 * @Description: 
 * @Project: igate320_v3
 * com.yhte.igate.commons.data QueryBean.java
 * Copyright(c) YHTE
 * http://www.yhte.net/
 * @date Created on 2011-6-15-下午01:59:12
 * @author longwei
 * @version 0.1
 */
package com.common;

import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * @ClassName: QueryBean
 * @Description: 查询类基类
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class PageBean implements Serializable {
	
	/**
     * @Fields serialVersionUID :
     */ 
    private static final long serialVersionUID = -6569344783432557640L;
    /**
     * 总数
     */
    private Integer total = 0;
    /**
     * 分页.
     */
    private Integer page = 1;
    /**
     * 起始记录.
     */
    private Integer start = 0;
    
    /**
     * ibatits中分页使用的起始记录
     */
//    private Integer ibatitsStart;
   
    public Integer getIbatitsStart() {
		return this.calcStart();
	}

	/**
     * 结束记录.
     */
//    private Integer end;
    
	/**
     * 每页记录数.
     */
    private Integer limit = 2;

    /**
     * 排序列.
     */
    private String order;
    /**
     * 排序方式.
     */
    private String orderType;
    
    /**
     * action
     * v: view
     * e: edit
     * a: add
     */
    private String a = "v";
	

    public String getA() {
		return a;
	}

	public void setA(String a) {
		this.a = a;
	}

    
    public Integer getEnd() {
		if(start == null){
			return limit;
		}
		if (limit == null) {
		    return 0;
		}
    	return start + limit;
	}
    
    /**
     * @return the page
     */
    public Integer getPage() {
        return page;
    }
    /**
     * @param page the page to set
     */
    public void setPage(Integer page) {
        this.page = page;
    }
    /**
     * @return the limit
     */
    public Integer getLimit() {
        return limit;
    }
    /**
     * @param limit the limit to set
     */
    public void setLimit(Integer limit) {
        this.limit = limit;
    }
    /**
     * @return the start
     */
    public Integer getStart() {
    	if (null != page) {
            limit = (limit == null) ? 0 : limit;
            return (page - 1) * limit;
        } else {
            return 0;
        }
    }
    /**
     * @param start the start to set
     */
    public void setStart(Integer start) {
        this.start = start;
    }
    /**
     * @return the order
     */
    public String getOrder() {
        return order;
    }
    /**
     * @param order the order to set
     */
    public void setOrder(String order) {
        this.order = order;
    }
    
    public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

	/**
     * @return the orderType
     */
    public String getOrderType() {
        return orderType;
    }
    /**
     * @param orderType the orderType to set
     */
    public void setOrderType(String orderType) {
        this.orderType = orderType;
    }
    
    /**
     * @Title: calcStart
     * @Description: 计算起始记录数
     * @return      .
     * @throws
     */
    public Integer calcStart() {
        if (page != null) {
            limit = (limit == null) ? 0 : limit;
            this.start = (page - 1) * limit;
        } else {
            this.start = 0;
        }
        return start;
    }
}
